<%-- 
    Document   : Edit
    Created on : Nov 25, 2012, 11:58:34 PM
    Author     : Admin
--%>

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.DateFormat"%>
<%@page import="edu.fpt.common.Plans"%>
<%@page import="Connection.PlanDAL"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>HelloWOrd</h1>
        <%
            int id = Integer.parseInt((session.getAttribute("id")) + "");
            String name = request.getParameter("edit_name");
            String type = request.getParameter("edit_type");
            String dateBegin = request.getParameter("dateBegin");
            String dateEnd = request.getParameter("dateEnd");
            String dateOccurence = request.getParameter("date");
            String kind = request.getParameter("edit_kind");
            String amount = request.getParameter("edit_amount");
            DateFormat formatter;
            Date date1, date2, date3;
            formatter = new SimpleDateFormat("yy-MM-dd");
            if (dateOccurence != null) {
                date1=date3=null;
                date2 = (Date) formatter.parse(dateOccurence);
            }else{
                 date1 = (Date) formatter.parse(dateBegin);                
                date3 = (Date) formatter.parse(dateEnd);
                date2=null;
            }
            out.println(date1);
            out.println(date2);
            out.println(date3);
           PlanDAL.update(id, name, type, amount, date2, date1, date3, kind);
            response.sendRedirect("BudgetPlanMainPage.jsp");
//        String 
//        out.println(id);
//        Plans entity=new Plans(id,);
//            Integer id=Integer.parseInt(request.getParameter("ItemID"));
//            PlanDAL.delete(id);
%>
    </body>
</html>
